package com.sysd.mail.smtp;


import com.sysd.mail.entity.bean.Email;
import com.sysd.mail.entity.bean.User;
import io.netty.channel.Channel;
import lombok.Data;

/**
 * project: mail
 *
 * @author bsh
 * @description SmtpSession
 * @dataTime 2023/3/27 17:05
 * @company 丽水信阳软件科技有限公司
 */
@Data
public class SmtpSession {
    private Channel channel;
    private Email email = new Email();
    private boolean isMailTransactionInProcess;
    private boolean isDataProcess;
    private StringBuilder buf;
    private int loginProcessCount;
    private User user;
    private boolean isLoginProcess;
    private String hello;
    private boolean isLogin;

    public SmtpSession(Channel channel) {
        this.channel = channel;
    }

    /**
     * 发送消息
     *
     * @param message message
     */
    public void write(String message) {
        this.channel.writeAndFlush(message);
    }

    /**
     * 重置邮件信息
     */
    public void resetMailTransaction() {
        this.email = new Email();
        this.setDataProcess(false);
        this.setMailTransactionInProcess(false);
    }

}
